package com.mini.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.FieldNameConstants;
import org.apache.commons.collections.CollectionUtils;

import java.util.*;
import java.util.stream.Collectors;

import static com.mini.util.BusinessUtil.divisionResultNormal;

/**
 * Created with meng.
 * User: meng5
 * Date: 2019-10-30
 * Description:
 */
@Data
@FieldNameConstants
@AllArgsConstructor
@NoArgsConstructor
@Builder
@ApiModel(value = "数据统计对象")
public class MiniStatisticDataAllVO {

    @ApiModelProperty(value = "id")
    private Long id;
    @ApiModelProperty(value = "计划名称")
    private String planName;
    @ApiModelProperty(value = "计划id")
    private String planId;
    @ApiModelProperty(value = "pv")
    private Long pv  = 0L;
    @ApiModelProperty(value = "uv")
    private Long uv  = 0L;
    @ApiModelProperty(value = "表单名片")
    private Long formCardTotal  = 0L;
    @ApiModelProperty(value = "支付名片")
    private Long payCardTotal  = 0L;
    @ApiModelProperty(value = "小课流水")
    private Double courseMoney  = 0.0;
    @ApiModelProperty(value = "加微人数")
    private Long addWxTotal  = 0L;
    @ApiModelProperty(value = "未加微人数=支付名片数-加微人数")
    private Long unAddWxTotal;
    @ApiModelProperty(value = "工作室id")
    private String workRoomId;
    @ApiModelProperty(value = "工作室名称")
    private String workRoomName;
    @ApiModelProperty(value = "负责人id")
    private Long respId;
    @ApiModelProperty(value = "负责人名称")
    private String respName;
    @ApiModelProperty(value = "创建时间")
    private Date createTime;
    @ApiModelProperty(value = "更新时间")
    private Date updateTime;
    @ApiModelProperty(value = "是否有效：1-有效，0-无效")
    private Integer isUsed;
    @ApiModelProperty(value = "小课业务id")
    private Long miniLessonId;
    @ApiModelProperty(value = "统计日期")
    private Date miniDate;
    @ApiModelProperty(value = "大课流水")
    private Double bigCourseMoney  = 0.0;
    @ApiModelProperty(value = "[20200722]大课流水")
    private Double bigCourseMoneyAll  = 0.0;

    @ApiModelProperty(value = "app注册数量")
    private Long appRegisterNum  = 0L;

    @ApiModelProperty(value = "发送短信数量")
    private Long smsSendNum  = 0L;

    @ApiModelProperty(value = "领取优惠劵的数量")
    private Long getCouponNum = 0L;


    @ApiModelProperty(value = "运营组ID")
    private Long groupId;

    @ApiModelProperty(value = "运营组名称")
    private String groupName;

    @ApiModelProperty(value = "渠道标识")
    private String channelCode;

    @ApiModelProperty(value = "渠道名称")
    private String channelName;

    @ApiModelProperty(value = "运营组IDs")
    private String groupIds;

    @ApiModelProperty(value = "运营组名称s")
    private String groupNames;

    @ApiModelProperty(value = "大课订单")
    private Long bigCourseOrderCount = 0L;

    @ApiModelProperty(value = "有赞流水")
    private Double youzanMoney = 0.0;

    @ApiModelProperty(value = "集团流水")
    private Double companyMoney = 0.0;

    @ApiModelProperty(value = "集团退款")
    private Double companyRefund = 0.0;

    @ApiModelProperty(value = "有赞退款")
    private Double youzanRefund = 0.0;

    @ApiModelProperty(value = "直播带货订单数")
    private Long liveSellCount = 0L;

    @ApiModelProperty(value = "直播带货流水")
    private Double liveSellMoney = 0.0;

    public Double getLiveSellMoney() {
        return Double.valueOf(divisionResultNormal(liveSellMoney));
    }

    @ApiModelProperty(value = "小程序流水")
    private Double xcxMoney = 0.0;

    @ApiModelProperty(value = "小程序退款")
    private Double xcxRefund = 0.0;

    @ApiModelProperty(value = "显示字段,ALL 为全部显示,其他情况为 字段名称用,分割")
    private String fields = "ALL";

    @ApiModelProperty(value = "小程序退款单数")
    private Long xcxRefundCount = 0L;

    @ApiModelProperty(value = "有赞退款单数")
    private Long youzanRefundCount = 0L;

    @ApiModelProperty(value = "集团退款单数")
    private Long companyRefundCount = 0L;

    @ApiModelProperty(value = "小课站点名称")
    private String miniLessonName;

    @ApiModelProperty(value = "小课名称")
    private String lessonName;

    @ApiModelProperty(value = "[20200722]有赞流水(全部）")
    private Double youzanMoneyAll = 0D;
    @ApiModelProperty(value = "[20200722]直播带货订单数(全)")
    private Long liveSellCountAll = 0L;
    @ApiModelProperty(value = "[20200722]直播带货流水(全)")
    private Double liveSellMoneyAll = 0D;
    @ApiModelProperty(value = "[20200722]小程序流水(全)")
    private Double xcxMoneyAll = 0D;

    @ApiModelProperty(value = "站点类型 0：飞天 1：传统")
    private Integer siteType;

    @ApiModelProperty(value = "站点类型 0：飞天 1：传统")
    private String siteTypeName;

    @ApiModelProperty(value = "机会数")
    private Long chanceTotal = 0L;

    @ApiModelProperty(value = "项目名称")
    private String itemName;

    @ApiModelProperty(value = "项目id")
    private Integer itemId;

    @ApiModelProperty(value = "已支付星图站点")
    private String xingtuSite;

    @ApiModelProperty(value = "SKU")
    private String skuName;

    @ApiModelProperty(value = "skuCode")
    private String skuCode;

    @ApiModelProperty(value = "创意")
    private String idea;



    @ApiModelProperty(value = "未支付星图站点")
    private String unPaySiteId;
    @ApiModelProperty(value = "已支付星图站点")
    private String paySiteId;
    @ApiModelProperty(value = "业务线")
    private String businessType;

    //xyf add 增加展点消数据
    @ApiModelProperty(value = "现金")
    private Double cash=0.0;

    @ApiModelProperty(value = "消费")
    private Double cost=0.0;

    @ApiModelProperty(value = "广告计划名称")
    private String campaignName;

    @ApiModelProperty(value = "点击")
    private Long click = 0L;

    @ApiModelProperty(value = "展现数")
    private Long showCount = 0L;

    //计算指标
    @ApiModelProperty(value = "展现成本cpm=现金*1000 / 展现数")
    private Double cpm;

    @ApiModelProperty(value="广告的点击率 = 点击次数 / 展现次数")
    private Double ctr;

    @ApiModelProperty(value="点击成本 = 现金 / 点击次数")
    private Double cpc;

    @ApiModelProperty(value="表单成本 = 现金 / 表单名片数")
    private Double formCardCost;

    @ApiModelProperty(value="表单转化率 = 表单名片数 / 点击数")
    private Double formCardTransfer;

    @ApiModelProperty(value="支付名片成本 = 现金 / 支付名片数")
    private Double payCardCost;

    @ApiModelProperty(value="支付转化率 = 支付名片数 / 表单名片数")
    private Double payCardTransfer;

    @ApiModelProperty(value="加微率 = 加微人数 / 支付名片数")
    private Double addWxTransfer = 0.0;

    @ApiModelProperty(value="机会成本 = 现价 / 机会数")
    private Double chanceCost = 0.0;

    @ApiModelProperty(value="唯一标示")
    private String unionId;

    @ApiModelProperty(value="是否是总计行，1-是 0-否")
    private Integer total=0;

    public Double getAddWxTransfer(){
        Long addWxCount = getAddWxTotal();
        Long payCardCount = getPayCardTotal();
        if(addWxCount == null || payCardCount == null || payCardCount.longValue()==0){
            return 0.0d;
        }
        addWxTransfer = ((double)addWxCount / (double)payCardCount);
        return addWxTransfer;
    }


    //大课流水 = 有赞流水-退款 + 集团流水-退款 + 小程序大课流水-退款
    public Double getBigCourseMoney(){
        Double youzanMoney = getYouzanMoney()==null?0.0d:getYouzanMoney();
        Double youzanRefund = getYouzanRefund()==null?0.0d:getYouzanRefund();
        Double xcxMoney = getXcxMoney()==null?0.0d:getXcxMoney();
        Double xcxRefund = getXcxRefund()==null?0.0d:getXcxRefund();
        Double companyMoney = getCompanyMoney()==null?0.0d:getCompanyMoney();
        Double companyRefund = getCompanyRefund()==null?0.0d:getCompanyRefund();

        return  youzanMoney-youzanRefund+xcxMoney-xcxRefund+companyMoney-companyRefund;
    }

    //大课流水 = 有赞流水-退款 + 集团流水-退款 + 小程序大课流水-退款
    public Double getBigCourseMoneyAll(){
        Double youzanMoneyAll = getYouzanMoneyAll()==null?0.0d:getYouzanMoneyAll();
        Double youzanRefund = getYouzanRefund()==null?0.0d:getYouzanRefund();
        Double xcxMoneyAll = getXcxMoneyAll()==null?0.0d:getXcxMoneyAll();
        Double xcxRefund = getXcxRefund()==null?0.0d:getXcxRefund();
        Double companyMoney = getCompanyMoney()==null?0.0d:getCompanyMoney();
        Double companyRefund = getCompanyRefund()==null?0.0d:getCompanyRefund();

        return  youzanMoneyAll-youzanRefund+xcxMoneyAll-xcxRefund+companyMoney-companyRefund;
    }


    @ApiModelProperty(value="订单消转 = 大课单数 / 支付名片数")
    private Double orderSellConversion =0.0;

    public Double getOrderSellConversion(){
        Long bigCounrseOrderCount = getBigCourseOrderCount();
        Long payCardCount = getPayCardTotal();
        if(bigCounrseOrderCount == null || payCardCount == null || payCardCount.longValue()==0){
            return 0.0d;
        }
        orderSellConversion = ((double)bigCounrseOrderCount / (double)payCardCount);
        return orderSellConversion;
    }

    @ApiModelProperty(value="加微消转 = 大课单数 / 加微人数")
    private Double addWxSellConversion =0.0;

    public Double getAddWxSellConversion(){
        Long bigCounrseOrderCount = getBigCourseOrderCount();
        Long addWxCount = getAddWxTotal();
        if(bigCounrseOrderCount == null || addWxCount == null || addWxCount.longValue()==0){
            return 0.0d;
        }
        addWxSellConversion = ((double)bigCounrseOrderCount / (double)addWxCount);
        return addWxSellConversion;
    }

    @ApiModelProperty(value="ROI = 推广费用 / 大课流水")
    private Double ROI =0.0;
    public Double getROI(){
        Double bigCounrseMoney = getBigCourseMoney();
        Double promotionCost = getPromotionCost();
        if(promotionCost == null || bigCounrseMoney == null || bigCounrseMoney.longValue()==0){
            return 0.0d;
        }
        ROI = ((double)promotionCost / (double)bigCounrseMoney);
        return ROI;
    }

    @ApiModelProperty(value="表名单名片网销 = 表单名片数 / 点击数")
    private Double formSellConversion =0.0;
    public Double getFormSellConversion(){
        Long formCardCount = getFormCardTotal();
        Long click = getClick();
        if(formCardCount == null || click == null || click.longValue()==0){
            return 0.0d;
        }
        formSellConversion = ((double)formCardCount / (double)click);
        return formSellConversion;
    }

    @ApiModelProperty(value="支付名片网销 = 支付名片数 / 点击数")
    private Double payCardSellConversion =0.0;

    public Double getPayCardSellConversion(){
        Long payCardTotal = getPayCardTotal();
        Long click = getClick();
        if(payCardTotal == null || click == null || click.longValue()==0){
            return 0.0d;
        }
        payCardSellConversion = ((double)payCardTotal / (double)click);
        return payCardSellConversion;
    }

    @ApiModelProperty(value="退费单数 = 所有退费单数")
    private Long refundCount =0L;

    public Long getRefundCount(){

        Long xcxRefundCount = getXcxRefundCount()==null?0L:getXcxRefundCount();
        Long youzanRefundCount = getYouzanRefundCount()==null?0L:getYouzanRefundCount();
        Long companyRefundCount = getCompanyRefundCount()==null?0L:getCompanyRefundCount();

        refundCount = xcxRefundCount+youzanRefundCount+companyRefundCount;
        return refundCount;
    }

    @ApiModelProperty(value="退费金额 = 所有退费流水")
    private Double refundMoney =0.0;

    public Double getRefundMoney(){

        Double xcxRefund = getXcxRefund()==null?0.0d:getXcxRefund();
        Double youzanRefund = getYouzanRefund()==null?0.0d:getYouzanRefund();
        Double companyRefund = getCompanyRefund()==null?0.0d:getCompanyRefund();

        refundMoney = xcxRefund+youzanRefund+companyRefund;
        return refundMoney;
    }

    @ApiModelProperty(value="ARPU = 大课流水 / 大课单数")
    private Double ARPU =0.0;

    public Double getARPU(){
        Double bigCourseMoney = getBigCourseMoney();
        Long bigCourseOrderCount = getBigCourseOrderCount();
        if(bigCourseMoney == null || bigCourseOrderCount == null || bigCourseOrderCount.longValue()==0){
            return 0.0d;
        }
        ARPU = ((double)bigCourseMoney / (double)bigCourseOrderCount);
        return ARPU;
    }

    @ApiModelProperty(value="RPA = 大课流水 / 加微人数")
    private Double RPA =0.0;

    public Double getRPA(){
        Double bigCourseMoney = getBigCourseMoney();
        Long addWxTotal = getAddWxTotal();
        if(bigCourseMoney == null || addWxTotal == null || addWxTotal.longValue()==0){
            return 0.0d;
        }
        RPA = ((double)bigCourseMoney / (double)addWxTotal);
        return RPA;
    }

    @ApiModelProperty(value="CPA = 推广费用 / 加微人数")
    private Double CPA =0.0;

    public Double getCPA(){
        Double promotionCost = getPromotionCost();
        Long addWxTotal = getAddWxTotal();
        if(promotionCost == null || addWxTotal == null || addWxTotal.longValue()==0){
            return 0.0d;
        }
        CPA = ((double)promotionCost / (double)addWxTotal);
        return CPA;
    }

    @ApiModelProperty(value="直播带货销转 = 直播带货成单数 / 支付名片数")
    private Double liveSellConversion =0.0;

    public Double getLiveSellConversion(){
        Long payCardTotal = getPayCardTotal();
        Long liveSellTotal = getLiveSellCount();
        if(liveSellTotal == null || payCardTotal == null || payCardTotal.longValue()==0){
            return 0.0d;
        }
        liveSellConversion = ((double)liveSellTotal / (double)payCardTotal);
        return liveSellConversion;
    }

    @ApiModelProperty(value="推广费用 = 现金-小课流水")
    private Double promotionCost =0.0;

    public Double getPromotionCost(){
        if(Objects.nonNull(promotionCost) && promotionCost!= 0){
            return promotionCost;
        }
        Double cash = getCash()==null?0.0d:getCash();
        Double courseMoney = getCourseMoney()==null?0.0d:getCourseMoney();
        promotionCost = cash - courseMoney;
        return promotionCost;
    }






    public Double getCtr() {
        Long click = getClick();
        Long impression = getShowCount();
        if(click == null || impression == null || impression.longValue() == 0){
            return 0.0d;
        }
        ctr = ((double)click / (double)impression);
        return ctr;
    }

    public Double getCpc() {
        Long click = getClick();
        Double cash = getCash();
        if(cash == null || click == null || click.longValue() == 0){
            return 0.0d;
        }
        cpc = (cash / (double)click);
        return cpc;
    }

    //展现成本cpm=现金*1000 / 展现数
    public Double getCpm() {
        Double cash = this.getCash();
        Long impre = getShowCount();
        if(cash == null || impre == null || impre.longValue() == 0){
            return 0.0d;
        }

        cpm = (cash * 1000d / (double)impre);
        return cpm;
    }

    public Double getFormCardCost() {
        Long formCardTotal = getFormCardTotal();
        Double cash = this.getCash();
        if(formCardTotal == null || cash == null || formCardTotal.longValue() == 0){
            return 0.0d;
        }
        formCardCost = (cash / (double)formCardTotal);
        return formCardCost;
    }

    public Double getFormCardTransfer() {
        Long formCardTotal = getFormCardTotal();
        Long click = this.getClick();
        if(formCardTotal == null || click == null || click.longValue() == 0){
            return 0.0d;
        }
        formCardTransfer = (formCardTotal / (double)click);
        return formCardTransfer;
    }



    public Double getPayCardCost() {
        Long payCardTotal = getPayCardTotal();
        Double cash = this.getCash();
        if(payCardTotal == null || cash == null || payCardTotal.longValue() == 0){
            return 0.0d;
        }
        payCardCost = (cash / (double)payCardTotal);
        return payCardCost;
    }

    public Double getPayCardTransfer() {
        Long formCardTotal = getFormCardTotal();
        Long payCardTotal = this.getPayCardTotal();
        if(payCardTotal == null || formCardTotal == null || formCardTotal.longValue() == 0){
            return 0.0d;
        }
        payCardTransfer = (payCardTotal / (double)formCardTotal);
        return payCardTransfer;
    }

    public Double getChanceCost() {
        Double cash = this.getCash();
        Long chanceTotal = this.getChanceTotal();
        if(chanceTotal == null || cash == null || chanceTotal.longValue() == 0){
            return 0.0d;
        }
        chanceCost = (cash / (double)chanceTotal);
        return chanceCost;
    }

    public String getSiteTypeName() {
        if(siteType == null || siteType == 0){
            return "小课业务";
        }else {
            return "传统机会";
        }
    }

    public Long getUnAddWxTotal() {
        Long total = getPayCardTotal() == null ? 0L : getPayCardTotal();
        Long add = getAddWxTotal() == null ? 0L : getAddWxTotal();
        unAddWxTotal = total - add;
        return unAddWxTotal;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("MiniStatisticDataAllVO{");
        sb.append("id=").append(id);
        sb.append(", planName='").append(planName).append('\'');
        sb.append(", planId='").append(planId).append('\'');
        sb.append(", pv=").append(pv);
        sb.append(", uv=").append(uv);
        sb.append(", formCardTotal=").append(formCardTotal);
        sb.append(", payCardTotal=").append(payCardTotal);
        sb.append(", courseMoney=").append(courseMoney);
        sb.append(", addWxTotal=").append(addWxTotal);
        sb.append(", unAddWxTotal=").append(unAddWxTotal);
        sb.append(", workRoomId='").append(workRoomId).append('\'');
        sb.append(", workRoomName='").append(workRoomName).append('\'');
        sb.append(", respId='").append(respId).append('\'');
        sb.append(", respName='").append(respName).append('\'');
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", isUsed=").append(isUsed);
        sb.append(", miniLessonId='").append(miniLessonId).append('\'');
        sb.append(", miniDate=").append(miniDate);
        sb.append(", bigCourseMoney=").append(bigCourseMoney);
        sb.append(", bigCourseMoneyAll=").append(bigCourseMoneyAll);
        sb.append(", appRegisterNum=").append(appRegisterNum);
        sb.append(", smsSendNum=").append(smsSendNum);
        sb.append(", getCouponNum=").append(getCouponNum);
        sb.append(", groupId=").append(groupId);
        sb.append(", groupName='").append(groupName).append('\'');
        sb.append(", channelCode='").append(channelCode).append('\'');
        sb.append(", channelName='").append(channelName).append('\'');
        sb.append(", groupIds='").append(groupIds).append('\'');
        sb.append(", groupNames='").append(groupNames).append('\'');
        sb.append(", bigCourseOrderCount=").append(bigCourseOrderCount);
        sb.append(", youzanMoney=").append(youzanMoney);
        sb.append(", companyMoney=").append(companyMoney);
        sb.append(", companyRefund=").append(companyRefund);
        sb.append(", youzanRefund=").append(youzanRefund);
        sb.append(", liveSellCount=").append(liveSellCount);
        sb.append(", liveSellMoney=").append(liveSellMoney);
        sb.append(", xcxMoney=").append(xcxMoney);
        sb.append(", xcxRefund=").append(xcxRefund);
        sb.append(", fields='").append(fields).append('\'');
        sb.append(", xcxRefundCount=").append(xcxRefundCount);
        sb.append(", youzanRefundCount=").append(youzanRefundCount);
        sb.append(", companyRefundCount=").append(companyRefundCount);
        sb.append(", miniLessonName='").append(miniLessonName).append('\'');
        sb.append(", lessonName='").append(lessonName).append('\'');
        sb.append(", youzanMoneyAll=").append(youzanMoneyAll);
        sb.append(", liveSellCountAll=").append(liveSellCountAll);
        sb.append(", liveSellMoneyAll=").append(liveSellMoneyAll);
        sb.append(", xcxMoneyAll=").append(xcxMoneyAll);
        sb.append(", siteType=").append(siteType);
        sb.append(", siteTypeName='").append(siteTypeName).append('\'');
        sb.append(", chanceTotal=").append(chanceTotal);
        sb.append(", itemName='").append(itemName).append('\'');
        sb.append(", itemId=").append(itemId);
        sb.append(", xingtuSite='").append(xingtuSite).append('\'');
        sb.append(", skuName='").append(skuName).append('\'');
        sb.append(", skuCode='").append(skuCode).append('\'');
        sb.append(", idea='").append(idea).append('\'');
        sb.append(", unPaySiteId='").append(unPaySiteId).append('\'');
        sb.append(", paySiteId='").append(paySiteId).append('\'');
        sb.append(", businessType='").append(businessType).append('\'');
        sb.append(", cash=").append(cash);
        sb.append(", cost=").append(cost);
        sb.append(", campaignName='").append(campaignName).append('\'');
        sb.append(", click=").append(click);
        sb.append(", showCount=").append(showCount);
        sb.append(", cpm=").append(cpm);
        sb.append(", ctr=").append(ctr);
        sb.append(", cpc=").append(cpc);
        sb.append(", formCardCost=").append(formCardCost);
        sb.append(", formCardTransfer=").append(formCardTransfer);
        sb.append(", payCardCost=").append(payCardCost);
        sb.append(", payCardTransfer=").append(payCardTransfer);
        sb.append(", addWxTransfer=").append(addWxTransfer);
        sb.append(", chanceCost=").append(chanceCost);
        sb.append(", unionId='").append(unionId).append('\'');
        sb.append(", total=").append(total);
        sb.append(", orderSellConversion=").append(orderSellConversion);
        sb.append(", addWxSellConversion=").append(addWxSellConversion);
        sb.append(", ROI=").append(ROI);
        sb.append(", formSellConversion=").append(formSellConversion);
        sb.append(", payCardSellConversion=").append(payCardSellConversion);
        sb.append(", refundCount=").append(refundCount);
        sb.append(", refundMoney=").append(refundMoney);
        sb.append(", ARPU=").append(ARPU);
        sb.append(", RPA=").append(RPA);
        sb.append(", CPA=").append(CPA);
        sb.append(", liveSellConversion=").append(liveSellConversion);
        sb.append(", promotionCost=").append(promotionCost);
        sb.append('}');
        return sb.toString();
    }

    public static List<MiniStatisticDataAllVO> sortedAsc(List<MiniStatisticDataAllVO> data,String  param){
        if (CollectionUtils.isEmpty(data)){
            return null;
        }
        List<MiniStatisticDataAllVO> res=new ArrayList<>();
        if (Objects.isNull(param)){
            return data;
        }
        if (param.equals("cash")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCash)).collect(Collectors.toList());
        }
        if (param.equals("cost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCost)).collect(Collectors.toList());
        }
        if (param.equals("promotionCost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPromotionCost)).collect(Collectors.toList());
        }
        if (param.equals("showCount")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getShowCount)).collect(Collectors.toList());
        }
        if (param.equals("cpm")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCpm)).collect(Collectors.toList());
        }
        if (param.equals("cpc")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCpc)).collect(Collectors.toList());
        }
        if (param.equals("ctr")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCtr)).collect(Collectors.toList());
        }
        if (param.equals("formCardTotal")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormCardTotal)).collect(Collectors.toList());
        }
        if (param.equals("formCardCost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormCardCost)).collect(Collectors.toList());
        }
        if (param.equals("formCardTransfer")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormCardTransfer)).collect(Collectors.toList());
        }
        if (param.equals("payCardTotal")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardTotal)).collect(Collectors.toList());
        }
        if (param.equals("payCardCost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardCost)).collect(Collectors.toList());
        }
        if (param.equals("payCardTransfer")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardTransfer)).collect(Collectors.toList());
        }
        if (param.equals("addWxTotal")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getAddWxTotal)).collect(Collectors.toList());
        }
        if (param.equals("addWxTransfer")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getAddWxTransfer)).collect(Collectors.toList());
        }
        if (param.equals("courseMoney")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCourseMoney)).collect(Collectors.toList());
        }
        if (param.equals("bigCourseOrderCount")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getBigCourseOrderCount)).collect(Collectors.toList());
        }
        if (param.equals("bigCourseMoney")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getBigCourseMoney)).collect(Collectors.toList());
        }
        if (param.equals("orderSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getOrderSellConversion)).collect(Collectors.toList());
        }
        if (param.equals("addWxSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getAddWxSellConversion)).collect(Collectors.toList());
        }
        if (param.equals("roi")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getROI)).collect(Collectors.toList());
        }
        if (param.equals("formSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormSellConversion)).collect(Collectors.toList());
        }
        if (param.equals("payCardSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardSellConversion)).collect(Collectors.toList());
        }
        if (param.equals("rpa")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getRPA)).collect(Collectors.toList());
        }
        if (param.equals("cpa")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCPA)).collect(Collectors.toList());
        }
        if (param.equals("liveSellCount")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getLiveSellCount)).collect(Collectors.toList());
        }
        if (param.equals("liveSellMoney")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getLiveSellMoney)).collect(Collectors.toList());
        }
        if (param.equals("liveSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getLiveSellConversion)).collect(Collectors.toList());
        }
        return res;
    }

    public static List<MiniStatisticDataAllVO> sortedDesc(List<MiniStatisticDataAllVO> data,String  param){
        if (CollectionUtils.isEmpty(data) || Objects.isNull(param)){
            return null;
        }
        List<MiniStatisticDataAllVO> res=new ArrayList<>();
        if (Objects.isNull(param)){
            return data;
        }
        if (param.equals("cash")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCash,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("cost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCost,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("promotionCost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPromotionCost,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("showCount")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getShowCount,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("cpm")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCpm,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("cpc")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCpc,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("ctr")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCtr,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("formCardTotal")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormCardTotal,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("formCardCost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormCardCost,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("formCardTransfer")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormCardTransfer,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("payCardTotal")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardTotal,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("payCardCost")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardCost,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("payCardTransfer")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardTransfer,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("addWxTotal")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getAddWxTotal,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("addWxTransfer")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getAddWxTransfer,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("courseMoney")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCourseMoney,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("bigCourseOrderCount")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getBigCourseOrderCount,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("bigCourseMoney")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getBigCourseMoney,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("orderSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getOrderSellConversion,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("addWxSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getAddWxSellConversion,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("roi")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getROI,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("formSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getFormSellConversion,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("payCardSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getPayCardSellConversion,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("rpa")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getRPA,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("cpa")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getCPA,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("liveSellCount")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getLiveSellCount,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("liveSellMoney")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getLiveSellMoney,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        if (param.equals("liveSellConversion")){
            res= data.stream().sorted(Comparator.comparing(MiniStatisticDataAllVO::getLiveSellConversion,Comparator.reverseOrder())).collect(Collectors.toList());
        }
        return res;
    }
}